package com.ljw.food_order_server.controller;


import com.ljw.food_order_server.entity.MyWindow;
import com.ljw.food_order_server.service.impl.MyWindowServiceImpl;
import com.ljw.food_order_server.util.R;
import com.ljw.food_order_server.vo.WindowStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 窗口 前端控制器
 * </p>
 *
 * @author ljw
 * @since 2021-07-31
 */
@RestController
@RequestMapping("/my_window")
public class MyWindowController {

    @Autowired
    private MyWindowServiceImpl myWindowService;

    /**
     * 根据地理位置positionId获取窗口
     * @param positionId
     * @return
     */
    @GetMapping("/getWindowsByPosition")
    public R getWindowsByPosition(@RequestParam Integer positionId){
        List<MyWindow> windows = myWindowService.getWindows(positionId);
        return R.getR().ok(windows);
    }

    @GetMapping("/getStream")
    public R getStream(@RequestParam Integer positionId){
        return R.getR().ok(myWindowService.getStream(positionId));
    }

}

